<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<body>
<head>
<script type="text/javascript" src="projectBase__PUBLIC__/js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="projectBase__PUBLIC__/js/lhgdialog.js"></script>
<script type="text/javascript">

function showAddLevelTwoMenu(){
	if($('#menuLevelOne').val()=='#'){
		alert("请选择上级菜单");
		return;
	}
 $.dialog({content: 'url:__URL__/addLeveltwonewMenu/menuid/'+$('#menuLevelOne').val(),height:90,ok:false},'id').title("添加二级菜单");
}

function showHtmlEditor(id){
	var url='url:__URL__/menuEdit/id/'+id;
	 $.dialog({content:url }).title("添加窗体");
}

function deleteMenu(id){
	$('#menuid').val(id);
	if(confirm("是否确认删除?")){
		//$('#deleteForm').submit();
		
		$.ajax({
			  url: '__APP__/AddMenu/deleteMenu',
			  dateType: "json",
			  data:{menuid:id},
			  success: function(data) {
				 var re= eval("(" + data + ")");
			  if(re.status=='1'){
					//api.parent().location.reload(true);
					window.location.reload();
			  }
			  }
			});
	}
}

function getSecondLevelMenu(id){
	
	$('#menuid').val(id);
		$("#menu2Table").empty();
		$.ajax({
			  url: '__APP__/AddMenu/getSecondLevelMenu',
			  dateType: "json",
			  data:{menuid:id},
			  success: function(data) {
				 var re= eval("(" + data + ")");
			  if(re.status=='1'&&re.data){
				  if(re.data.length){
				  for(var i=0;i<re.data.length;i++){
					  var current=re.data[i];
  						$('#menu2Table').append('<tr><td nowrap>'+current.MENU_NAME+'&nbsp;</td>'+'<td><a href="#" class="btn green" onclick="deleteMenu('+current.MENU_ID+')">删除</a></td></TR>');
					 // $('#menu2Table').append();
					  //$('#menu2Table').append('<td><a href="#" class="btn green" onclick="showHtmlEditor('+current.MENU_ID+')">编辑内容</a></td></tr>');
				  }
				  }else{
					  
					  var item='<tr><td nowrap>'+re.data.MENU_NAME+'&nbsp;</td>'+'<td><a href="#" class="btn green" onclick="deleteMenu('+re.data.MENU_ID+')">删除</a></td>'+
					  '</tr>';
					  //<td><a href="#" class="btn green" onclick="showHtmlEditor('+re.data.MENU_ID+')">编辑内容</a></td>
					  $('#menu2Table').append(item);
				  }
				  //api.parent().location.reload(true);
			  }
			 }
		});
}
</script>
</head>
<form id="deleteForm" name="deleteForm" action="__APP__/AddMenu/deleteMenu">
<input type="hidden" id='menuid' name='menuid' />
</form>
<div style="align:center">

<select name="menuLevelOne" onchange="getSecondLevelMenu(this.value)" id="menuLevelOne">
<option value='#'>请选择</option>
<volist name="list" id="vo">
<option value="{$vo.MENU_ID}">{$vo.MENU_NAME}</option>
</volist>
</select>
<a href="#" class="button" onclick="showAddLevelTwoMenu()">添加二级菜单</a>
</div>
<table id='menu2Table' >
</table>
</body>
</html>